// @author: caoshi
// @date: 2021-06-14 10:21
package dao

import (
	"academic/global"
	"academic/model/entity"
)

// 表明
const tableName = "t_user"

var db = global.GvaDb.Table(tableName)

/**
通过用户名与密码查询用户
*/
func FindByUsernameAndPwd(username string, password string) (*entity.SysUser, error) {
	var user = &entity.SysUser{}
	var count int64

	db.Where("username = ? and password = ?", username, password)
	db.Find(&user).Count(&count)
	err := db.Error
	if err != nil || count == 0 {
		return nil, err
	}
	return user, nil
}

func UpdatePassword(id string, newPwd string) (success bool, err error) {
	return true, nil
}
